Skip to content

feat: optimize share section and share tab logic #8001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Jun 2, 2025

Conversation

LucasXu0
Copy link
Collaborator

@LucasXu0 LucasXu0 commented May 29, 2025

Feature Preview

  • new share menu design
  • new shared with me section design (next PR)
  • exclude the members/sites tab if user is guest
  • disable workspace editable fileds in workspace tab if user is guest
  • permission control:
    • if user is a guest, he can't get the view info that not in the shared views.
    • share private views

PR Checklist

  • My code adheres to AppFlowy's Conventions
  • I've listed at least one issue that this PR fixes in the description above.
  • I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes.
  • All existing tests are passing.

Summary by Sourcery

Refactor share tab and shared section features: unify naming conventions, externalize event/state classes, update repository implementations, adopt new ghost-button design, add shared section toggle behavior, and align tests accordingly

New Features:

  • Add expand/collapse toggle for the SharedSection UI

Enhancements:

  • Rename ShareWithUserBloc to ShareTabBloc and extract its events and state into separate files
  • Rename shared_section repository interfaces and implementations with Impl suffix and update imports
  • Replace static header widgets in SharedSection and Favorites with AFGhostIconTextButton and introduce mainAxisAlignment support
  • Streamline bloc logic by removing redundant result resets and conditionally rendering SharedPagesList based on isExpanded

Tests:

  • Update bloc and widget tests to use ShareTabBloc, SharedSectionBloc, and new repository implementations

Chores:

  • Reorganize file structure by moving event, state, and repository definitions into dedicated files
  • Move local repository classes to test folders and rename them with Impl suffix

Copy link
Contributor

sourcery-ai bot commented May 29, 2025

Reviewer's Guide

This PR overhauls the sharing feature by refactoring both the share tab and shared section blocs into explicit event/state files with manual classes (replacing Freezed), renaming repository interfaces and implementations to “*Impl”, enhancing UI components (collapsible shared section, updated button styling), and aligning tests to the new structure.

File-Level Changes

Change Details Files
Refactor share_tab bloc into manual event/state files
  • Rename ShareWithUserBloc to ShareTabBloc and update handler registrations
  • Extract events and states into share_tab_event.dart and share_tab_state.dart
  • Replace Freezed-generated classes with sealed and concrete event/state classes
  • Update all imports and method signatures to use new ShareTabEvent/ShareTabState
lib/features/share_tab/logic/share_tab_bloc.dart
lib/features/share_tab/logic/share_tab_event.dart
lib/features/share_tab/logic/share_tab_state.dart
various presentation and repository imports across share_tab
Refactor shared_section bloc with toggle and explicit files
  • Extract SharedSectionEvent and SharedSectionState into separate files
  • Rename repository interface to SharedPagesRepository and adjust constructor
  • Add SharedSectionToggleExpandedEvent and handle expand/collapse in bloc
  • Export new event/state files and remove Freezed dependency
lib/features/shared_section/logic/shared_section_bloc.dart
lib/features/shared_section/logic/shared_section_event.dart
lib/features/shared_section/logic/shared_section_state.dart
lib/features/shared_section/data/repositories/shared_pages_repository.dart
Rename and reorganize repository implementations
  • Append Impl suffix to repository classes (e.g., RustShareWithUserRepositoryImpl)
  • Move local/test repos into test folders and rename Local*RepositoryImpl
  • Update all import paths in production and test code
lib/features/share_tab/data/repositories/*_repository_impl.dart
lib/features/shared_section/data/repositories/*_repository_impl.dart
share_button.dart, share_tab.dart, tests under test/*
Enhance UI for shared section and favorites header
  • Use AFGhostIconTextButton.primary for SharedSectionHeader and FavoriteHeader
  • Add onTap callback and collapsible logic in SharedSection widget
  • Conditionally render SharedPagesList based on expanded state
  • Introduce mainAxisAlignment property in ghost button implementation
lib/features/shared_section/presentation/shared_section.dart
lib/features/shared_section/presentation/widgets/shared_section_header.dart
lib/workspace/presentation/home/menu/sidebar/favorites/favorite_folder.dart
packages/appflowy_ui/src/component/button/ghost_button/ghost_icon_text_button.dart
Align tests with new bloc/event/state and repository names
  • Update blocTest and widgetTest imports to ShareTabBloc/ShareTabEvent/ShareTabState
  • Reference *Impl repository classes in tests
  • Adjust SharedSectionBloc tests to use SharedPagesRepository interface
test/bloc_test/lib/features/share_tab/share_tab_bloc_test.dart
test/widget_test/lib/features/share_tab/*.dart
test/bloc_test/lib/features/share_section/shared_section_bloc_test.dart
test/widget_test/lib/features/shared_section/shared_section_header_test.dart

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @LucasXu0 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@LucasXu0 LucasXu0 force-pushed the guest_role_v2 branch 2 times, most recently from 10ce39a to e64717b Compare June 2, 2025 02:51
@LucasXu0 LucasXu0 merged commit d3566e3 into AppFlowy-IO:main Jun 2, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant